package br.com.diogenesistemas.dinggle.controller;

import br.com.diogenesistemas.dinggle.factory.AbstractCommandFactory;
import br.com.diogenesistemas.dinggle.command.Command;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Diógenes
 */
@WebServlet(name = "FrontController", urlPatterns = {"*.do"})

public class FrontController extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
            Command com = AbstractCommandFactory.getInstance().getCommand(request.getServletPath());
            com.execute(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
}
